package com.example.star_wars_luke;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

public class MainActivity extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		findViewById(R.id.call_vader).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Log.i("tag_MainActivity", "?>>:call_vader");
				Toast.makeText(v.getContext(), "?>>:call_vader", Toast.LENGTH_LONG).show();

				String packageName = "com.example.star_wars_vader";
				String className = "com.example.star_wars_vader.MainActivity";
				startActivity(
						new Intent().setClassName(packageName, className)
						.putExtra("im", "Luck~~~~")
						);
			}

		});
		findViewById(R.id.call_father).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Log.i("tag_MainActivity", "?>>:call_father");
				Toast.makeText(v.getContext(), "?>>:call_father", Toast.LENGTH_LONG).show();

				String action = "father";
				startActivity(new Intent(action));
			}
		});
		findViewById(R.id.call_helper).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Log.i("tag_MainActivity", "?>>:call_helper");
				Toast.makeText(v.getContext(), "?>>:call_helper", Toast.LENGTH_LONG).show();

				sendBroadcast(new Intent("help"));
			}
		});
		findViewById(R.id.call_teacher).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Log.i("tag_MainActivity", "?>>:call_teacher");
				Toast.makeText(v.getContext(), "?>>:call_teacher", Toast.LENGTH_LONG).show();

				String action = "teacher";
				startActivityForResult(new Intent(action), 100);

			}
		});
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		Toast.makeText(this, "?>>:ANS :::: >>" + requestCode + "," + resultCode + "," + "," + data.getStringExtra("im"), Toast.LENGTH_LONG).show();
		super.onActivityResult(requestCode, resultCode, data);
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}
